--[[
create date: 2017-5-23
auther: ldg 
description: 数据库请求对外引用文件，详看下面的示例

history:
-----------------------------------------------------------
v0.0.1 (2018/1/13)
1. 新增db.send函数，对于无需返回值的数据库调用不阻碍
-----------------------------------------------------------
]]
local skynet = require "skynet"


-----------------------------------------------------------
--调用时主要使用函数
-----------------------------------------------------------
local db = {}


--[[
数据库初始化
local sqlconf = {
        host = skynet.getenv "sql_host",
        port = skynet.getenv "sql_port",
        database = skynet.getenv "sql_database",
        user = skynet.getenv "sql_user",
        password = skynet.getenv "sql_password",
        max_packet_size = skynet.getenv "sql_max_packet_size",
}
db.init(sqlconf, 10)
--]]
function db.init(conf, max_db_num, isslave)
    local mysql = skynet.uniqueservice ("serviceMysql")
    skynet.call(mysql, "lua", "runService", conf, max_db_num, isslave)
end

return db